//
//  UIButton-Extension.swift
//  JGWB
//
//  Created by 付建国 on 2016/10/9.
//  Copyright © 2016年 sher. All rights reserved.
//

import UIKit

extension UIButton{
    
    //swift中的类方法 以class开头
    /*
    class func createButton(imageName : String, bgImageName : String) -> UIButton{
        
        let btn = UIButton()
        
        btn.setImage(UIImage.init(named: imageName), for: .normal)
        btn.setImage(UIImage.init(named: imageName + "_highlighted"), for: .highlighted)
        btn.setBackgroundImage(UIImage.init(named: bgImageName), for: .normal)
        btn.setBackgroundImage(UIImage.init(named: bgImageName + "_highlighted"), for: .highlighted)
        
        btn.sizeToFit()
        
        return btn
    }
    */
    convenience init(imageName : String, bgImageName : String){
        self.init()//必须加
        
        setImage(UIImage.init(named: imageName), for: .normal)
        setImage(UIImage.init(named: imageName + "_highlighted"), for: .highlighted)
        setBackgroundImage(UIImage.init(named: bgImageName), for: .normal)
        setBackgroundImage(UIImage.init(named: bgImageName + "_highlighted"), for: .highlighted)
        
        sizeToFit()
        
    }
}















